package com.whmskj.xjlhbc.mobile.controller;

import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.dto.ScanDto;
import com.whmskj.xjlhbc.service.IScanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "扫一扫",description = "扫一扫")
@RequestMapping("/scan")
public class ScanController {

    @Autowired
    private IScanService service;

    @GetMapping("/getDetail")
    @Operation(description = "获取设备详情",parameters = @Parameter(name = "code",description = "扫码获取的结果"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ScanDto.class})
    ))
    public AjaxResult getDetail(@RequestParam String code){
        ScanDto result = service.getDetail(code);
        return AjaxResult.success(result);
    }

}
